import vue from "vue"
import VueRouter from "vue-router"
import layout from "@/view/Main.vue"

//全局引入router
vue.use(VueRouter)

const routes = [

  { path: '/', redirect: '/login' },

  {
    path: '/Main',
    name: 'Main',
    //路由的懒加载
    component: () => import('@/view/Main.vue'),
  // redirect: '/home' ,

    children: [
      // {
      //   path: '/home',
      //   name: 'home',

      //   component: () => import('@/view/Home/home.vue')

      // },
      // {
      //   path: '/mall',
      //   name: 'mall',
      //   component: () => import('@/view/Mall/mall.vue')

      // },
      // {
      //   path: '/user',
      //   name: 'user',
      //   component: () => import('@/view/User/user.vue')

      // },
    ]
  },

  // {
  //   path: '/other',
  //   name: 'other',
  //   component: layout,
  //   children: [
  //     {
  //       path: '/page1',
  //       name: 'page1',
  //       component: () => import('@/view/Other/page1.vue')

  //     },
  //     {
  //       path: '/page2',
  //       name: 'page2',
  //       component: () => import('@/view/Other/page2.vue')

  //     },
  //   ]

  // },
  {
    path: '/login',
    name: 'login',

    component: () => import('@/view/login/login.vue')


  }
]

const router = new VueRouter({
  mode: 'history',
  routes

})
//解决路由导航双击出现报错问题
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router